package com.gjy.mywork.util;

import java.io.Serializable;
import java.util.Map;

/**
 * 定义ajax请求返回Json时数据
 * @author gjy
 *
 * 2018年1月30日下午2:45:58
 * @param 
 */
public class AjaxReturnVO implements Serializable {

	private static final long serialVersionUID = 3023474549141299233L;
	
	private String msg;
	
	private Object data;
	
	private boolean ok = true;
	
	private Map<String, Object> attrs;// 其他参数
	
	private Map<String, ?> maps;// 其他参数
	
	public AjaxReturnVO() {}
	
	public AjaxReturnVO(boolean success, String msg) {
        this.ok = success;
        this.msg = msg;
    }
	
	public AjaxReturnVO(boolean success) {
        this.ok = success;
        if(success)
        	this.msg = "操作成功";
        else
        	this.msg = "操作失败";
        
    }
	
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public boolean isOk() {
		return ok;
	}

	public void setOk(boolean ok) {
		this.ok = ok;
	}

	public Map<String, Object> getAttrs() {
		return attrs;
	}

	public void setAttrs(Map<String, Object> attrs) {
		this.attrs = attrs;
	}

	public void setFail(AjaxReturnVO vo,String msg) {
		vo.setOk(false);
		vo.setMsg("失败，错误代码:"+msg);
	}
	
	
	public static  AjaxReturnVO fail() {
        return new AjaxReturnVO(false);
    }

    public static  AjaxReturnVO fail(String msg) {
        return new AjaxReturnVO(false, msg);
    }
    
    public static  AjaxReturnVO ok() {
        return new AjaxReturnVO(true);
    }
    
    public static  AjaxReturnVO ok(String msg) {
        return new AjaxReturnVO(true,msg);
    }

	public Map<String, ?> getMaps() {
		return maps;
	}

	public void setMaps(Map<String, ?> maps) {
		this.maps = maps;
	}

	

}
